package mx.test;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;

import javax.annotation.Resource;

import mx.test.bean.User;
import mx.test.dao.IUserDao;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/Spring.xml")
@Transactional
@TransactionConfiguration(defaultRollback=false)
public class test {
	@Resource(name="iUserDao")
	private IUserDao ud;
	
	@Test
	public void testADD() {
		/*Method[] ms=ud.getClass().getDeclaredMethods();
		for(Method m:ms){
			if(Modifier.isAbstract(m.getModifiers())){
				System.out.println(m.getName());
			}
		}*/
		
		//System.out.println(ud);
		//增
		/*User u=new User("wangwu","1234","ww");
		ud.add(u);*/
		//删
		/*User u=new User();
		u.setId(8);
		ud.delete(u);*/
		//改
		//ud.update(new User(2,"Mingxuan","123444","mx"));
		//简单查询
		//System.out.println(ud.findById(2).toString());
		
		//测试复杂查询
		
		/*List<User> list=ud.findAll();
		//System.out.println(ud.findAll());
		for(Object u:list){
			System.out.println(u.toString());
		}*/
		System.out.println(ud.findusername());
	}

}
